package database

object Model {
  import slick.jdbc.PostgresProfile.api._
  import actors.Messages.CameraDevice
  import actors.Messages.Registration

  class RegistrationTable(tag: Tag) extends Table[Registration](tag, Some("raiden"), "Registration") {
    def id = column[String]("device_id", O.PrimaryKey)
    def name = column[String]("name")

    override def * =
      (id, name) <> (Registration.tupled, Registration.unapply)
  }

  class CameraDeviceTable(tag: Tag) extends Table[CameraDevice](tag, Some("raiden"), "Camera") {
    def id = column[String]("device_id", O.PrimaryKey)
    def name = column[String]("name")
    def manufacturer = column[String]("manufacturer")
    def quality = column[String]("quality")
    def width = column[Int]("width")
    def height = column[Int]("height")
    def streamURL = column[String]("stream_url")
    def status = column[String]("status")
    def onlineTime = column[String]("online_time")
    def offlineTime = column[String]("offline_time")
    def frameRate = column[Int]("frame_rate")
    def bitRate = column[Int]("bit_rate")

    override def * =
      (id, name, manufacturer, quality, width, height, streamURL, status, onlineTime, offlineTime, frameRate, bitRate) <>
        (CameraDevice.tupled, CameraDevice.unapply)
  }

  // "API entry point"
  lazy val registrationTable = TableQuery[RegistrationTable]
  lazy val cameraDeviceTable = TableQuery[CameraDeviceTable]
}
